import matplotlib.pyplot as plt


x = [1, 2, 3, 4, 5, 6, 7]
new_x_label_theta = [0, 8, 16, 32, 64, 128, 256, 512]
new_x_label_z = [0, 4, 6, 8, 10, 12, 14, 16]

# RESULTS FOR SHORT BEARING
# For z in [4, 16]
# For theta in [8, 512]

nthetas_z4 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z4 = [0.849075147341031, 0.6988670917544382, 0.3857893404962915, 0.2095602900013927, 0.11419405894997163, 0.06590306255775218, 0.041785468289520025]
error_fdm_z4 = [0.701124717897403, 0.22690097538292686, 0.14753251011742552, 0.055648156478164616, 0.015649146184622622, 0.0030953374911853494, 0.012177269302883808]
time_fem_z4 = [0.03534507751464844, 0.07963299751281738, 0.16815781593322754, 0.31949520111083984, 0.6122748851776123, 1.229684591293335, 2.4413411617279053]
time_fdm_z4 = [0.00034880638122558594, 0.0008258819580078125, 0.0010144710540771484, 0.003548145294189453, 0.01126861572265625, 0.0395359992980957, 0.2762782573699951]

nthetas_z6 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z6 = [0.8486938665909065, 0.8229183358221873, 0.586076219489858, 0.34361503962085105, 0.1868895952814414, 0.10333200415297335, 0.061140802738028466]
error_fdm_z6 = [0.7026444599853987, 0.2279323475180085, 0.1485467196102256, 0.05654322635798159, 0.016487382996457325, 0.002284730943332602, 0.011380259516553528]
time_fem_z6 = [0.07882142066955566, 0.12640619277954102, 0.25672197341918945, 0.5077848434448242, 1.0184216499328613, 2.038954496383667, 4.20762300491333]
time_fdm_z6 = [0.0007512569427490234, 0.0013418197631835938, 0.0027971267700195312, 0.006236553192138672, 0.019138097763061523, 0.08376431465148926, 0.4403362274169922]

nthetas_z8 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z8 = [0.5748450788976529, 0.8576216560876464, 0.7132962075834924, 0.45823603596916673, 0.2558361921950965, 0.1395087476329351, 0.07952235461143753]
error_fdm_z8 = [0.7030644379199044, 0.22821761145829414, 0.1488273077205227, 0.056790744978233616, 0.016719118782121067, 0.002060668142080884, 0.011159972167911897]
time_fem_z8 = [0.07868552207946777, 0.17778444290161133, 0.39842796325683594, 0.7094316482543945, 1.425260066986084, 2.9936447143554688, 6.066305160522461]
time_fdm_z8 = [0.000598907470703125, 0.0011849403381347656, 0.0038230419158935547, 0.009494304656982422, 0.04216313362121582, 0.20302152633666992, 0.9411799907684326]

nthetas_z10 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z10 = [0.4705810602283921, 0.8528092892609225, 0.7909329831053546, 0.5531375728482556, 0.32084286969961934, 0.17499473094148435, 0.09765019218277753]
error_fdm_z10 = [0.703237428886895, 0.22833514453228765, 0.1489429233755053, 0.05689272046336999, 0.016814583357836865, 0.001968368897446547, 0.011069230352233785]
time_fem_z10 = [0.10180306434631348, 0.22227144241333008, 0.51031494140625, 0.9511411190032959, 1.9692115783691406, 3.8051815032958984, 8.133606672286987]
time_fdm_z10 = [0.0007584095001220703, 0.0022590160369873047, 0.0035088062286376953, 0.01616501808166504, 0.05543708801269531, 0.34441232681274414, 1.5155088901519775]

nthetas_z12 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z12 = [0.6196039936499075, 0.7858478700212392, 0.8370953103184815, 0.6298757497725798, 0.381449435550939, 0.20977341751471132, 0.11563915924248537]
error_fdm_z12 = [0.7033250323688012, 0.22839467089823987, 0.149001480670251, 0.05694436612310657, 0.016862929648895193, 0.001921626618077324, 0.011023277277248915]
time_fem_z12 = [0.1232001781463623, 0.2742271423339844, 0.5676846504211426, 1.1001324653625488, 2.2611098289489746, 4.708553791046143, 10.33855652809143]
time_fdm_z12 = [0.0009684562683105469, 0.003215312957763672, 0.004136800765991211, 0.013259410858154297, 0.07117605209350586, 0.4359302520751953, 2.671900749206543]

nthetas_z14 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z14 = [0.7205535935225602, 0.5986677886339532, 0.8628680878656317, 0.6909703972639236, 0.4373733082321067, 0.2437533895902927, 0.13350749087643965]
error_fdm_z14 = [0.7033754282193369, 0.22842891691166983, 0.149035169790026, 0.056974077892320535, 0.016890742707336284, 0.0018947366305710198, 0.010996841454227059]
time_fem_z14 = [0.14538073539733887, 0.3287932872772217, 0.6475975513458252, 1.3021259307861328, 2.7980144023895264, 5.658313989639282, 13.171401262283325]
time_fdm_z14 = [0.001758575439453125, 0.0024373531341552734, 0.0056612491607666016, 0.02993607521057129, 0.13699865341186523, 0.6479601860046387, 4.099093437194824]

nthetas_z16 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z16 = [0.7207975881444006, 0.4519917142655018, 0.8750976356729918, 0.7391289599523903, 0.48852570902194875, 0.27683942976468706, 0.1512492375256958]
error_fdm_z16 = [0.7034070510106194, 0.22845040667608535, 0.1490563103292474, 0.05699272221407494, 0.01690819535855911, 0.0018778633176131858, 0.010980253182699618]
time_fem_z16 = [0.1691422462463379, 0.3666534423828125, 0.7441680431365967, 1.5188336372375488, 3.161128282546997, 6.65733790397644, 15.862739086151123]
time_fdm_z16 = [0.0012049674987792969, 0.004221200942993164, 0.008289098739624023, 0.042374372482299805, 0.20453405380249023, 0.9607250690460205, 6.714038848876953]

# Plot time
ax = plt.gca()
ax.plot(x, time_fem_z4[0:7], label="FEM; Nz=4")
ax.plot(x, time_fem_z8[0:7], label="FEM; Nz=8")
ax.plot(x, time_fem_z12[0:7], label="FEM; Nz=12")
ax.plot(x, time_fem_z16[0:7], label="FEM; Nz=16")
ax.plot(x, time_fdm_z4[0:7], 'b--', label="FDM; Nz=4")
ax.plot(x, time_fdm_z8[0:7], 'm--', label="FDM; Nz=8")
ax.plot(x, time_fdm_z12[0:7], 'g--', label="FDM; Nz=12")
ax.plot(x, time_fdm_z16[0:7], 'r--', label="FDM; Nz=16")
ax.set_xlabel("Ntheta")
ax.set_ylabel("Time")
ax.legend(loc='best')
ax.set_title("Short bearing time comparison")

plt.gca().set_xticklabels(new_x_label_theta)

plt.show()

# Plot error
ax = plt.gca()
ax.plot(x, error_fem_z4[0:7], label="FEM; Nz=4")
ax.plot(x, error_fem_z8[0:7], label="FEM; Nz=8")
ax.plot(x, error_fem_z12[0:7], label="FEM; Nz=12")
ax.plot(x, error_fem_z16[0:7], label="FEM; Nz=16")
ax.plot(x, error_fdm_z4[0:7], 'b--', label="FDM; Nz=4")
ax.plot(x, error_fdm_z8[0:7], 'm--', label="FDM; Nz=8")
ax.plot(x, error_fdm_z12[0:7], 'g--', label="FDM; Nz=12")
ax.plot(x, error_fdm_z16[0:7], 'r--', label="FDM; Nz=16")
ax.set_xlabel("Ntheta")
ax.set_ylabel("Relative error")
ax.legend(loc='best')
ax.set_title("Short bearing error comparison")

plt.gca().set_xticklabels(new_x_label_theta)

plt.show()

# RESULTS FOR SHORT BEARING
# For theta in [8, 512]
# For z in [4, 16]

nz_t8 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t8 = [0.849075147341031, 0.8486938665909065, 0.5748450788976529, 0.4705810602283921, 0.6196039936499075, 0.7205535935225602, 0.7207975881444006]
error_fdm_t8 = [0.701124717897403, 0.7026444599853987, 0.7030644379199044, 0.703237428886895, 0.7033250323688012, 0.7033754282193369, 0.7034070510106194]
time_fem_t8 = [0.03484630584716797, 0.07220244407653809, 0.08200454711914062, 0.10480976104736328, 0.13003873825073242, 0.15004515647888184, 0.1733992099761963]
time_fdm_t8 = [0.0004684925079345703, 0.0004584789276123047, 0.0009603500366210938, 0.0007472038269042969, 0.0009515285491943359, 0.0010657310485839844, 0.0014026165008544922]

nz_t16 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t16 = [0.6988670917544382, 0.8229183358221873, 0.8576216560876464, 0.8528092892609225, 0.7858478700212392, 0.5986677886339532, 0.4519917142655018]
error_fdm_t16 = [0.22690097538292686, 0.2279323475180085, 0.22821761145829414, 0.22833514453228765, 0.22839467089823987, 0.22842891691166983, 0.22845040667608535]
time_fem_t16 = [0.09021234512329102, 0.13010954856872559, 0.17331290245056152, 0.222761869430542, 0.27205538749694824, 0.31252169609069824, 0.3730301856994629]
time_fdm_t16 = [0.0005099773406982422, 0.0009136199951171875, 0.0018641948699951172, 0.0019073486328125, 0.0030982494354248047, 0.0023550987243652344, 0.002763986587524414]

nz_t32 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t32 = [0.3857893404962915, 0.586076219489858, 0.7132962075834924, 0.7909329831053546, 0.8370953103184815, 0.8628680878656317, 0.8750976356729918]
error_fdm_t32 = [0.14753251011742552, 0.1485467196102256, 0.1488273077205227, 0.1489429233755053, 0.149001480670251, 0.149035169790026, 0.1490563103292474]
time_fem_t32 = [0.1548023223876953, 0.30147695541381836, 0.4032166004180908, 0.49468088150024414, 0.5938522815704346, 0.6894512176513672, 0.7452301979064941]
time_fdm_t32 = [0.0010755062103271484, 0.0021424293518066406, 0.0038132667541503906, 0.005293846130371094, 0.006785392761230469, 0.00878286361694336, 0.009206295013427734]

nz_t64 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t64 = [0.2095602900013927, 0.34361503962085105, 0.45823603596916673, 0.5531375728482556, 0.6298757497725798, 0.6909703972639236, 0.7391289599523903]
error_fdm_t64 = [0.055648156478164616, 0.05654322635798159, 0.056790744978233616, 0.05689272046336999, 0.05694436612310657, 0.056974077892320535, 0.05699272221407494]
time_fem_t64 = [0.3619823455810547, 0.5105462074279785, 0.7052438259124756, 0.9234123229980469, 1.1113202571868896, 1.3099806308746338, 1.5239243507385254]
time_fdm_t64 = [0.003415346145629883, 0.00684356689453125, 0.00912928581237793, 0.015456199645996094, 0.019031763076782227, 0.021267414093017578, 0.042444705963134766]

nz_t128 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t128 = [0.11419405894997163, 0.1868895952814414, 0.2558361921950965, 0.32084286969961934, 0.381449435550939, 0.4373733082321067, 0.48852570902194875]
error_fdm_t128 = [0.015649146184622622, 0.016487382996457325, 0.016719118782121067, 0.016814583357836865, 0.016862929648895193, 0.016890742707336284, 0.01690819535855911]
time_fem_t128 = [0.6209719181060791, 1.0825574398040771, 1.4758422374725342, 1.903637170791626, 2.2498393058776855, 2.7030842304229736, 3.125671863555908]
time_fdm_t128 = [0.010762929916381836, 0.022391080856323242, 0.04037928581237793, 0.041399478912353516, 0.07235360145568848, 0.10563850402832031, 0.18734288215637207]

nz_t256 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t256 = [0.06590306255775218, 0.10333200415297335, 0.1395087476329351, 0.17499473094148435, 0.20977341751471132, 0.2437533895902927, 0.27683942976468706]
error_fdm_t256 = [0.0030953374911853494, 0.002284730943332602, 0.002060668142080884, 0.001968368897446547, 0.001921626618077324, 0.0018947366305710198, 0.0018778633176131858]
time_fem_t256 = [1.2376627922058105, 2.0634427070617676, 2.9340057373046875, 3.8636860847473145, 4.732395172119141, 5.7035510540008545, 6.68587851524353]
time_fdm_t256 = [0.02737712860107422, 0.07046246528625488, 0.18716812133789062, 0.260364294052124, 0.40134239196777344, 0.6033151149749756, 0.9447743892669678]

nz_t512 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t512 = [0.041785468289520025, 0.061140802738028466, 0.07952235461143753, 0.09765019218277753, 0.11563915924248537, 0.13350749087643965, 0.1512492375256958]
error_fdm_t512 = [0.012177269302883808, 0.011380259516553528, 0.011159972167911897, 0.011069230352233785, 0.011023277277248915, 0.010996841454227059, 0.010980253182699618]
time_fem_t512 = [2.548619031906128, 4.231797933578491, 6.1587653160095215, 8.25516939163208, 10.402963161468506, 13.165261268615723, 16.03892970085144]
time_fdm_t512 = [0.22885560989379883, 0.44761204719543457, 1.421915054321289, 1.5490734577178955, 2.702932834625244, 3.827035903930664, 7.201216697692871]

# Plot time
ax = plt.gca()
ax.plot(x, error_fem_t64[0:7], label="FEM; Nt=64")
ax.plot(x, error_fem_t128[0:7], label="FEM; Nt=128")
ax.plot(x, error_fem_t256[0:7], label="FEM; Nt=256")
ax.plot(x, error_fem_t512[0:7], label="FEM; Nt=512")
ax.plot(x, error_fdm_t64[0:7], 'b--', label="FDM; Nt=64")
ax.plot(x, error_fdm_t128[0:7], 'm--', label="FDM; Nt=128")
ax.plot(x, error_fdm_t256[0:7], 'g--', label="FDM; Nt=256")
ax.plot(x, error_fdm_t512[0:7], 'r--', label="FDM; Nt=512")
ax.set_xlabel("Nz")
ax.set_ylabel("Relative error")
ax.legend(loc='best')
ax.set_title("Short bearing error comparison")

plt.gca().set_xticklabels(new_x_label_z)

plt.show()

# Plot error
ax = plt.gca()
ax.plot(x, time_fem_t64[0:7], label="FEM; Nt=64")
ax.plot(x, time_fem_t128[0:7], label="FEM; Nt=128")
ax.plot(x, time_fem_t256[0:7], label="FEM; Nt=256")
ax.plot(x, time_fem_t512[0:7], label="FEM; Nt=512")
ax.plot(x, time_fdm_t64[0:7], 'b--', label="FDM; Nt=64")
ax.plot(x, time_fdm_t128[0:7], 'm--', label="FDM; Nt=128")
ax.plot(x, time_fdm_t256[0:7], 'g--', label="FDM; Nt=256")
ax.plot(x, time_fdm_t512[0:7], 'r--', label="FDM; Nt=512")
ax.set_xlabel("Nz")
ax.set_ylabel("Time")
ax.legend(loc='best')
ax.set_title("Short bearing time comparison")

plt.gca().set_xticklabels(new_x_label_z)

plt.show()


# RESULTS FOR LONG BEARING
# For z in [4, 16]
# For theta in [8, 512]

nthetas_z4 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z4 = [3.2566245437370958, 4.6038662797516885, 5.9812057813410515, 6.945161830173632, 7.511661974992722, 7.81668500078152, 7.972472258219632]
error_fdm_z4 = [0.8004877276398236, 0.1756833608613899, 0.040104832955239256, 0.01630429489423181, 0.015708897742916336, 0.01921073798426978, 0.021016388373060947]
time_fem_z4 = [0.03481912612915039, 0.08282232284545898, 0.15468192100524902, 0.30661773681640625, 0.6308467388153076, 1.2411105632781982, 2.4929497241973877]
time_fdm_z4 = [0.0005173683166503906, 0.0004982948303222656, 0.001627206802368164, 0.0023393630981445312, 0.007088661193847656, 0.03718233108520508, 0.249603271484375]

nthetas_z6 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z6 = [3.0489379028339734, 3.8833632193349032, 5.5657018476565785, 6.897460439232315, 7.740263332417531, 8.213296159305143, 8.461190771326484]
error_fdm_z6 = [0.8394752954863439, 0.1690330744684007, 0.02385574247496394, 0.002071392254621684, 0.003128851980618373, 0.00018703494362341583, 0.0019867661427103336]
time_fem_z6 = [0.07066464424133301, 0.13041281700134277, 0.27063465118408203, 0.5627269744873047, 1.0745418071746826, 2.0773138999938965, 4.310821056365967]
time_fdm_z6 = [0.0008108615875244141, 0.0009093284606933594, 0.0018832683563232422, 0.006444454193115234, 0.020544052124023438, 0.11100029945373535, 0.4448893070220947]

nthetas_z8 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z8 = [5.3236398365869135, 3.1962466830536, 4.944024231256562, 6.518613345118129, 7.598591923826823, 8.231077865328995, 8.570634564589366]
error_fdm_z8 = [0.8531871441980978, 0.1700510041277709, 0.022209473047586997, 0.00433199970959427, 0.005539859451936453, 0.0022784059301439543, 0.0004874799673108968]
time_fem_z8 = [0.07979655265808105, 0.17215275764465332, 0.3510403633117676, 0.7156291007995605, 1.4498488903045654, 2.94461989402771, 6.183768272399902]
time_fdm_z8 = [0.0006427764892578125, 0.0018820762634277344, 0.0029921531677246094, 0.011309146881103516, 0.03782939910888672, 0.19570517539978027, 0.9178783893585205]

nthetas_z10 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z10 = [5.567244209083342, 2.7471746262874257, 4.379028570737225, 6.0923503017379765, 7.356069949908472, 8.128436237382543, 8.552512145964112]
error_fdm_z10 = [0.8592273450349899, 0.17083104728586873, 0.021887155108623994, 0.0049104817862910734, 0.00618248934072023, 0.0029425309998822665, 0.0011558837969198265]
time_fem_z10 = [0.10396528244018555, 0.22928524017333984, 0.4608895778656006, 1.0540566444396973, 1.8756463527679443, 3.8919732570648193, 8.292112588882446]
time_fdm_z10 = [0.0012040138244628906, 0.001905202865600586, 0.005294084548950195, 0.011296749114990234, 0.056223154067993164, 0.2854175567626953, 1.4988880157470703]

nthetas_z12 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z12 = [6.057330397196865, 2.7888170015137903, 3.894219251586806, 5.686412233868469, 7.0957713128324995, 7.994244009091455, 8.498729943921811]
error_fdm_z12 = [0.8623733794933917, 0.17130389414461875, 0.02180037782742087, 0.005127522241699936, 0.006432342970004956, 0.0032029017475385564, 0.0014185125081903692]
time_fem_z12 = [0.12452411651611328, 0.26926469802856445, 0.5553293228149414, 1.128037691116333, 2.332667112350464, 4.77371621131897, 10.52711820602417]
time_fdm_z12 = [0.0009453296661376953, 0.001901865005493164, 0.0068721771240234375, 0.020449399948120117, 0.07851886749267578, 0.43423891067504883, 2.6742215156555176]

nthetas_z14 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z14 = [6.263086976966385, 3.598088499753951, 3.480889494707527, 5.312942633648348, 6.836750035992312, 7.8486655294868966, 8.42965193559659]
error_fdm_z14 = [0.8642095902065857, 0.171599010893243, 0.02177310239711979, 0.005229860936589634, 0.00655362285940767, 0.0033300912367309993, 0.0015470171635995694]
time_fem_z14 = [0.1472947597503662, 0.3147470951080322, 0.6539807319641113, 1.3556773662567139, 2.7470884323120117, 5.751894474029541, 13.286986112594604]
time_fdm_z14 = [0.0013272762298583984, 0.0023174285888671875, 0.005893707275390625, 0.033243656158447266, 0.10020303726196289, 0.620734453201294, 3.9650354385375977]

nthetas_z16 = [8, 16, 32, 64, 128, 256, 512]
error_fem_z16 = [7.109009714317892, 4.289588271954611, 3.1334179642954036, 4.972647947227957, 6.585911904036443, 7.699712094584285, 8.353528396183155]
error_fdm_z16 = [0.8653715646008311, 0.17179264785096254, 0.0217642659695794, 0.005285835545128558, 0.00662149786800681, 0.0034016154530803985, 0.0016193697393355863]
time_fem_z16 = [0.17176055908203125, 0.38808751106262207, 0.7484800815582275, 1.54207181930542, 3.191133499145508, 6.724010467529297, 16.045817852020264]
time_fdm_z16 = [0.0014171600341796875, 0.003932952880859375, 0.01081705093383789, 0.036717891693115234, 0.20408225059509277, 0.9529426097869873, 6.842027425765991]

# Plot time
ax = plt.gca()
ax.plot(x, time_fem_z4[0:7], label="FEM; Nz=4")
ax.plot(x, time_fem_z8[0:7], label="FEM; Nz=8")
ax.plot(x, time_fem_z12[0:7], label="FEM; Nz=12")
ax.plot(x, time_fem_z16[0:7], label="FEM; Nz=16")
ax.plot(x, time_fdm_z4[0:7], 'b--', label="FDM; Nz=4")
ax.plot(x, time_fdm_z8[0:7], 'm--', label="FDM; Nz=8")
ax.plot(x, time_fdm_z12[0:7], 'g--', label="FDM; Nz=12")
ax.plot(x, time_fdm_z16[0:7], 'r--', label="FDM; Nz=16")
ax.set_xlabel("Ntheta")
ax.set_ylabel("Time")
ax.legend(loc='best')
ax.set_title("Long bearing time comparison")

plt.gca().set_xticklabels(new_x_label_theta)

plt.show()

# Plot error
ax = plt.gca()
ax.plot(x, error_fem_z4[0:7], label="FEM; Nz=4")
ax.plot(x, error_fem_z8[0:7], label="FEM; Nz=8")
ax.plot(x, error_fem_z12[0:7], label="FEM; Nz=12")
ax.plot(x, error_fem_z16[0:7], label="FEM; Nz=16")
ax.plot(x, error_fdm_z4[0:7], 'b--', label="FDM; Nz=4")
ax.plot(x, error_fdm_z8[0:7], 'm--', label="FDM; Nz=8")
ax.plot(x, error_fdm_z12[0:7], 'g--', label="FDM; Nz=12")
ax.plot(x, error_fdm_z16[0:7], 'r--', label="FDM; Nz=16")
ax.set_xlabel("Ntheta")
ax.set_ylabel("Relative error")
ax.legend(loc='best')
ax.set_title("Long bearing error comparison")

plt.gca().set_xticklabels(new_x_label_theta)

plt.show()

# RESULTS FOR LONG BEARING
# For theta in [8, 512]
# For z in [4, 16]

nz_t8 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t8 = [3.2566245437370958, 3.0489379028339734, 5.3236398365869135, 5.567244209083342, 6.057330397196865, 6.263086976966385, 7.109009714317892]
error_fdm_t8 = [0.8004877276398236, 0.8394752954863439, 0.8531871441980978, 0.8592273450349899, 0.8623733794933917, 0.8642095902065857, 0.8653715646008311]
time_fem_t8 = [0.03471660614013672, 0.06611919403076172, 0.08903956413269043, 0.1412367820739746, 0.12764883041381836, 0.15161991119384766, 0.17808294296264648]
time_fdm_t8 = [0.0003237724304199219, 0.0004982948303222656, 0.0006237030029296875, 0.0009517669677734375, 0.0009167194366455078, 0.0010519027709960938, 0.001247406005859375]

nz_t16 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t16 = [4.6038662797516885, 3.8833632193349032, 3.1962466830536, 2.7471746262874257, 2.7888170015137903, 3.598088499753951, 4.289588271954611]
error_fdm_t16 = [0.1756833608613899, 0.1690330744684007, 0.1700510041277709, 0.17083104728586873, 0.17130389414461875, 0.171599010893243, 0.17179264785096254]
time_fem_t16 = [0.07554936408996582, 0.1372661590576172, 0.1704697608947754, 0.22461223602294922, 0.3076152801513672, 0.3661167621612549, 0.41350221633911133]
time_fdm_t16 = [0.0008499622344970703, 0.0014095306396484375, 0.001424551010131836, 0.0015845298767089844, 0.002093791961669922, 0.003300905227661133, 0.003920078277587891]

nz_t32 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t32 = [5.9812057813410515, 5.5657018476565785, 4.944024231256562, 4.379028570737225, 3.894219251586806, 3.480889494707527, 3.1334179642954036]
error_fdm_t32 = [0.040104832955239256, 0.02385574247496394, 0.022209473047586997, 0.021887155108623994, 0.02180037782742087, 0.02177310239711979, 0.0217642659695794]
time_fem_t32 = [0.1577446460723877, 0.2552003860473633, 0.3557610511779785, 0.4635498523712158, 0.6071169376373291, 0.7053656578063965, 0.7708392143249512]
time_fdm_t32 = [0.0024416446685791016, 0.0019137859344482422, 0.003978729248046875, 0.005263566970825195, 0.006591796875, 0.008330106735229492, 0.011574506759643555]

nz_t64 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t64 = [6.945161830173632, 6.897460439232315, 6.518613345118129, 6.0923503017379765, 5.686412233868469, 5.312942633648348, 4.972647947227957]
error_fdm_t64 = [0.01630429489423181, 0.002071392254621684, 0.00433199970959427, 0.0049104817862910734, 0.005127522241699936, 0.005229860936589634, 0.005285835545128558]
time_fem_t64 = [0.317638635635376, 0.5124301910400391, 0.7138111591339111, 0.9571888446807861, 1.149660348892212, 1.4887874126434326, 1.5708057880401611]
time_fdm_t64 = [0.0023148059844970703, 0.004219532012939453, 0.0089263916015625, 0.010729789733886719, 0.01776289939880371, 0.027953624725341797, 0.032886505126953125]

nz_t128 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t128 = [7.511661974992722, 7.740263332417531, 7.598591923826823, 7.356069949908472, 7.0957713128324995, 6.836750035992312, 6.585911904036443]
error_fdm_t128 = [0.015708897742916336, 0.003128851980618373, 0.005539859451936453, 0.00618248934072023, 0.006432342970004956, 0.00655362285940767, 0.00662149786800681]
time_fem_t128 = [0.6302862167358398, 1.0537126064300537, 1.6059937477111816, 2.0371437072753906, 2.3337957859039307, 2.7266695499420166, 3.193699359893799]
time_fdm_t128 = [0.008475065231323242, 0.02194356918334961, 0.04635190963745117, 0.044828176498413086, 0.07102370262145996, 0.09927940368652344, 0.1893017292022705]

nz_t256 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t256 = [7.81668500078152, 8.213296159305143, 8.231077865328995, 8.128436237382543, 7.994244009091455, 7.8486655294868966, 7.699712094584285]
error_fdm_t256 = [0.01921073798426978, 0.00018703494362341583, 0.0022784059301439543, 0.0029425309998822665, 0.0032029017475385564, 0.0033300912367309993, 0.0034016154530803985]
time_fem_t256 = [1.2744066715240479, 2.1499743461608887, 3.0162932872772217, 4.030896186828613, 4.836036205291748, 5.839847803115845, 6.8980700969696045]
time_fdm_t256 = [0.028868913650512695, 0.07240962982177734, 0.25649166107177734, 0.26764869689941406, 0.4106125831604004, 0.6054081916809082, 0.9332554340362549]

nz_t512 = [4, 6, 8, 10, 12, 14, 16]
error_fem_t512 = [7.972472258219632, 8.461190771326484, 8.570634564589366, 8.552512145964112, 8.498729943921811, 8.42965193559659, 8.353528396183155]
error_fdm_t512 = [0.021016388373060947, 0.0019867661427103336, 0.0004874799673108968, 0.0011558837969198265, 0.0014185125081903692, 0.0015470171635995694, 0.0016193697393355863]
time_fem_t512 = [2.5318024158477783, 4.320987701416016, 6.162101984024048, 8.394293308258057, 10.57742977142334, 13.29473090171814, 16.13062858581543]
time_fdm_t512 = [0.19134521484375, 0.6536180973052979, 0.9320492744445801, 1.5217466354370117, 3.4175760746002197, 3.9380431175231934, 6.769510746002197]


# Plot time
ax = plt.gca()
ax.plot(x, error_fem_t8[0:7], label="FEM; Nt=8")
ax.plot(x, error_fem_t16[0:7], label="FEM; Nt=16")
ax.plot(x, error_fem_t32[0:7], label="FEM; Nt=32")
ax.plot(x, error_fem_t64[0:7], label="FEM; Nt=64")
ax.plot(x, error_fdm_t8[0:7], 'b--', label="FDM; Nt=8")
ax.plot(x, error_fdm_t16[0:7], 'm--', label="FDM; Nt=16")
ax.plot(x, error_fdm_t32[0:7], 'g--', label="FDM; Nt=32")
ax.plot(x, error_fdm_t64[0:7], 'r--', label="FDM; Nt=64")
ax.set_xlabel("Nz")
ax.set_ylabel("Relative error")
ax.legend(loc='upper right')
ax.set_title("Long bearing error comparison")

plt.gca().set_xticklabels(new_x_label_z)

plt.show()

# Plot error
ax = plt.gca()
ax.plot(x, time_fem_t8[0:7], label="FEM; Nt=8")
ax.plot(x, time_fem_t16[0:7], label="FEM; Nt=16")
ax.plot(x, time_fem_t32[0:7], label="FEM; Nt=32")
ax.plot(x, time_fem_t64[0:7], label="FEM; Nt=64")
ax.plot(x, time_fdm_t8[0:7], 'b--', label="FDM; Nt=8")
ax.plot(x, time_fdm_t16[0:7], 'm--', label="FDM; Nt=16")
ax.plot(x, time_fdm_t32[0:7], 'g--', label="FDM; Nt=32")
ax.plot(x, time_fdm_t64[0:7], 'r--', label="FDM; Nt=64")
ax.set_xlabel("Nz")
ax.set_ylabel("Relative error")
ax.legend(loc='best')
ax.set_title("Long bearing time comparison")

plt.gca().set_xticklabels(new_x_label_z)

plt.show()





